<template>
  <div>
    <!--  -->
    <crumbs @goBack="() => {}" :superiorMenu="['库存管理']" currentMenu="库存管理"></crumbs>
    <div class="cardBox">
      <div class="cardOne">
        <div class="inputBox">
          <a-input v-model="keyword" placeholder="仓库名称" @pressEnter="searchProcess(keyword)" />
        </div>
        <div class="listBox">
          <a-tree
            checkable
            showLine
            :tree-data="treeDataLeft"
            :replace-fields="replaceFieldsLeft"
            @check="onCheck"
            :selectable="false"
            v-model="selectedKeys"
          >
            <!-- <a-icon slot="switcherIcon" type="form" /> -->
            <!-- <span slot="icon"></span> -->
            <!-- <a-icon slot="icon" type="carry-out" /> -->
          </a-tree>
          <!-- <div
            :class="item.isSelect ? 'haveColor' : 'itemList'"
            v-for="(item, index) in messSingleProcessTaskStaticsDtoList"
            :key="index"
            @click="itemClick(item, index)"
          >
            <div class="itemLeft">{{ item.processName }}</div>
            <div class="itemRight">
              {{ item.notCompleteTaskNum }}/{{ item.taskNum }}
              <a-tooltip v-if="item.processName == '全部'" style="margin-left: 8px">
                <template slot="title">
                  <div>前一个数字代表可报工的任务</div>
                  <div>后一个数字代表所有的任务数</div>
                </template>
                <a-icon type="question-circle" theme="filled" style="color: rgba(170, 170, 170, 0.8)" />
              </a-tooltip>
            </div>
          </div> -->
        </div>
      </div>
      <div class="cardTwo">
        <a-card :bordered="false" size="small" style="height: 100%" :bodyStyle="computedWidth">
          <div class="topBox">
            <div>
              <a-button @click="handleShowFilter" icon="filter" style="margin-right: 10px">
                筛选 <span style="color: #1890ff; margin-left: 5px">{{ realFilterNum }}</span></a-button
              >
              <a-button @click="showColumn" icon="unordered-list" style="margin-right: 10px"> 设置列 </a-button>
            </div>
            <div>
              <PubExport
                :exportUrl="exportUrl"
                :columns="columns"
                :propForm="formatData()"
                :selectedRows="chooseArr"
                :sortForm="sortForm"
                :fullName="fullName"
              />
            </div>
          </div>
          <a-table
            row-key="goodsId"
            :key="tableKey"
            :columns="columns"
            :data-source="tableData"
            :pagination="false"
            :scroll="{ x: computedX, y: 'calc(100vh - 366px)' }"
            @change="tableChange"
            :row-selection="{
              selectedRowKeys: selectedRowKeys,
              columnTitle: ' ',
              onChange: onSelectChange,
            }"
            :components="drag(columns, 'STOCK_MANAGEMENT_LIST')"
          >
            <span
              slot="goodsCode"
              @click="handleDetail(record)"
              slot-scope="text, record"
              style="color: #1890ff; cursor: pointer"
              :title="text"
              >{{ text }}</span
            >
            <span slot="category" :title="record.categoryText" slot-scope="text, record">
              {{ record.categoryText }}
            </span>
            <span slot="type" slot-scope="text, record" :title="record.typeText">{{ record.typeText }}</span>
            <!-- <span slot="spec" slot-scope="text, record" :title="record.spec">
              {{  record.spec }}
            </span> -->
            <span
              slot="goodsQualifiedNum"
              slot-scope="text, record"
              :title="text"
              :style="{ color: checkColor(record) }"
            >
              {{ text }}
            </span>
            <span
              slot="goodsQualifiedNumText"
              slot-scope="text, record"
              :title="`${record.goodsQualifiedNumText}${record.assistUnit}`"
              :style="{ color: checkColor(record) }"
            >
              {{ `${record.goodsQualifiedNumText}${record.assistUnit}` }}
            </span>
            <span
              slot="goodsScrapNumText"
              slot-scope="text, record"
              :title="`${record.goodsScrapNumText}${record.assistUnit}`"
              :style="{ color: checkColor(record) }"
            >
              {{ `${record.goodsScrapNumText}${record.assistUnit}` }}
            </span>
            <span slot="securityNumTxt" slot-scope="text, record" :title="text ? `${text}${record.assistUnit}` : '-'">
              {{ text ? `${text}${record.assistUnit}` : '-' }}
            </span>
            <span slot="maxNumTxt" slot-scope="text, record" :title="text ? `${text}${record.assistUnit}` : '-'">
              {{ text ? `${text}${record.assistUnit}` : '-' }}
            </span>

            <!-- 输入框搜索 -->
            <div slot="searchDropdown" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
              <a-input
                :placeholder="checkPlaceholder(column.dataIndex)"
                v-model="tableFilterForm[column.dataIndex]"
                style="width: 188px; display: block"
              />
              <a-button
                type="primary"
                style="width: 80px; margin-left: 20px; display: block"
                @click="() => pubSearch(confirm, column.dataIndex, clearFilters)"
              >
                搜索
              </a-button>
            </div>
            <a-icon
              slot="searchIcon"
              slot-scope="filtered"
              type="search"
              :style="{ color: filtered ? '#108ee9' : undefined }"
            />
            <!-- 选择搜索 -->
            <div slot="selectDropdown" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
              <!-- <a-select
            v-if="column.dataIndex == 'category'"
            mode="multiple"
            :placeholder="checkPlaceholder(column.dataIndex)"
            style="width: 200px"
            v-model="tableFilterForm[column.dataIndex]"
          >
            <a-select-option v-for="item in statusList" :key="item.value" :value="item.value">
              {{ item.label }}
            </a-select-option>
          </a-select> -->
              <a-tree-select
                v-if="column.dataIndex == 'category'"
                allow-clear
                v-model="tableFilterForm[column.dataIndex]"
                :multiple="false"
                placeholder="请选择"
                style="width: 200px"
                :tree-data="treeData"
                :replaceFields="replaceFields"
                :show-checked-strategy="SHOW_PARENT"
                search-placeholder="请选择"
                @change="treeChange"
              />
              <a-select
                v-if="column.dataIndex == 'type'"
                mode="multiple"
                :placeholder="checkPlaceholder(column.dataIndex)"
                style="width: 200px"
                v-model="tableFilterForm[column.dataIndex]"
              >
                <a-select-option v-for="item in typeList" :key="item.value" :value="item.value">
                  {{ item.title }}
                </a-select-option>
              </a-select>
              <a-button
                type="primary"
                style="width: 80px; margin-left: 20px; display: block"
                @click="() => pubSearch(confirm, column.dataIndex, clearFilters)"
              >
                搜索
              </a-button>
            </div>
            <a-icon
              slot="selectIcon"
              slot-scope="filtered"
              type="filter"
              :style="{ color: filtered ? '#108ee9' : undefined }"
            />
            <!-- 操作 -->
            <span slot="actions" slot-scope="text, record">
              <span class="pubColor" @click="openBach(record)">水位管理</span>
            </span>
          </a-table>
        </a-card>
      </div>
    </div>
    <div
      class="uni-card"
      :style="{
        position: 'fixed',
        bottom: 0,
        right: 0,
        zIndex: 2,
        left: collapsed ? '79px' : '208px',
        background: '#fff',
        paddingLeft: '43px',
      }"
    >
      <div style="display: inline-block">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <!-- <span class='pubColor' @click="batchAction()" style="margin:0 0px 0 24px">批量删除</span> -->
        <span style="margin-left: 8px">
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }}
          <span class="pubColor" @click="clearArr" style="margin: 0 10px">清空</span>
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination
          :total="total"
          v-model="current"
          :page-size-options="pageSizeOptions"
          :page-size="pageSize"
          @change="onChangePage"
          @showSizeChange="onShowSizeChange"
          show-quick-jumper
          show-size-changer
        />
      </div>
    </div>
    <SetColumn
      columnName="设置列"
      ref="SetColumn"
      v-if="showSetColumn"
      @sureBtn="sureBtn"
      @cancelBtn="showSetColumn = false"
    />
    <!-- 筛选抽屉 -->
    <a-drawer width="500" :closable="true" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums }}</span>
        </div>
        <div class="uni-card" v-if="filteredNums > 0" style="background: #fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="checkShow(item.text)" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="物品编号">
                <a-input v-model="filterForm.goodsCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="物品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="规格">
                <a-input v-model="filterForm.spec" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="分类">
                <!-- <a-select mode="multiple" placeholder="请选择" v-model="filterForm.category" allowClear>
                  <a-select-option v-for="item in reportSelectList" :key="item.value" :value="item.value">
                    {{ item.label }}
                  </a-select-option>
                </a-select> -->
                <a-tree-select
                  allow-clear
                  v-model="filterForm.category"
                  :multiple="false"
                  placeholder="请选择"
                  style="width: 100%"
                  :tree-data="treeData"
                  :replaceFields="replaceFields"
                  :show-checked-strategy="SHOW_PARENT"
                  search-placeholder="请选择"
                  @change="treeChange"
                />
              </a-form-model-item>
              <a-form-model-item label="类型">
                <a-select mode="multiple" placeholder="请选择" v-model="filterForm.type">
                  <a-select-option v-for="item in typeList" :key="item.value" :value="item.value">
                    {{ item.title }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 水位管理 弹框 -->
    <a-modal
      v-model="addDialog"
      :bodyStyle="{ padding: '32px 32px 24px', boxSizing: 'border-box' }"
      :maskClosable="false"
      :title="clickType == 'newAdd' ? '新增仓库' : '编辑'"
      @cancel="cancelAdd"
    >
      <a-form-model ref="addForm" :model="newAddForm" :rules="addRules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-form-model-item label="安全库存：" prop="securityNum">
          <a-input :suffix="assistUnit" v-model="newAddForm.securityNum" placeholder="请输入" />
        </a-form-model-item>
        <a-form-model-item label="最大库存：" prop="maxNum">
          <a-input :suffix="assistUnit" v-model="newAddForm.maxNum" placeholder="请输入" />
        </a-form-model-item>
      </a-form-model>
      <template slot="footer">
        <a-button @click="cancelAdd">取消</a-button>
        <a-button type="primary" :loading="accloading" @click="saveAcction('addForm')">确定</a-button>
      </template>
    </a-modal>
    <windowDetail ref="windowDetail"></windowDetail>
  </div>
</template>
<script>
import moment from 'moment'
import { goodsList, categoryGetTree, goodsLogicDelBatch, goodsLogicDel, getDictModel } from '@/api/goodsManagement'
import { taskListApi, batchValidOrUpdateStatus, processTaskCompletionStatics, deleteTaskApi } from '@/api/productOrder'
import { columns, allColumn } from './allColumn.js'
import { getNewColumns, objArrFilter, subStrText, numFormat } from '@/utils/util'
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import { APILX } from '@/api/requestLx'
import { mapState } from 'vuex'
import { TreeSelect } from 'ant-design-vue'
import PubExport from '@/components/pubBtn/PubExport.vue'
import tableDragResize from '@/mixins/tableDragResize'
const SHOW_PARENT = TreeSelect.SHOW_PARENT
const treeData = []
const treeDataLeft = []
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    align: 'left',
    dataIndex: 'actions',
    ellipsis: true,
    width: 114,
    scopedSlots: { customRender: 'actions' },
  },
]
export default {
  components: {
    crumbs,
    SetColumn,
    PubExport,
    windowDetail: (resolve) => require(['@/views/warehouseManagement/goodsManagement/goodsManagementDetail'], resolve),
  },
  mixins: [tableDragResize],
  data() {
    return {
      selectedKeys: [],
      selectedKeysTree: '', //左侧仓库筛选
      assistUnit: '', //表单基本单位
      // 类型
      typeList: [],
      // 树分类
      treeData,
      SHOW_PARENT,
      treeSelectLael: '',
      replaceFields: {
        children: 'children',
        title: 'name',
        key: 'id',
        value: 'id',
      },
      // 新建
      clickType: '',
      accloading: false,
      addDialog: false,
      newAddForm: {
        securityNum: '',
        maxNum: '',
      },
      addRules: {
        maxNum: [{ required: true, message: '请输入', trigger: 'blur' }],
        securityNum: [
          { required: true, message: '请输入', trigger: 'blur' },
          // 正则校验只能输入最多保留四位小数的正数
          {
            pattern: /^(([1-9]\d{0,4})|0)(\.\d{1,4})?$/,
            message: '请输入正确的数字',
            trigger: 'blur',
          },
          //   {
          //     message: '该班组编号已存在',
          //     validator: (rule, value, callback) =>
          //       validateDuplicateValue('mess_team_group', 'team_code', value, queryId, callback),
          //   },
        ],
      },
      labelCol: { span: 4 },
      wrapperCol: { span: 17 },
      isEdit: false,
      // 左边 查询树
      treeDataLeftOld: [],
      treeDataLeft,
      replaceFieldsLeft: {
        children: 'list',
        title: 'warehouseName',
        key: 'warehouseId',
      },
      moment,
      numFormat,
      subStrText,
      dialogMessage: '',
      isOpen: true,
      columns,
      tableData: [],
      batchOverFiil: false,
      batchOverSuccess: false,
      //全选按钮
      listIndeterminate: false,
      current: 1,
      total: 0,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      showSetColumn: false,
      // 抽屉数据
      showFilter: false, // 筛选抽屉
      realFilterForm: {},
      tableFilterForm: {},
      filterForm: {
        type: [],
        category: [],
        goodsCode: '',
        goodsName: '',
      },
      filteredFormLable: {
        type: '类型',
        category: '分类',
        goodsCode: '工单编号',
        goodsName: '物品名称',
        spec: '规格',
      },
      statusList: [
        {
          label: '未开始',
          value: 'notStarted',
        },
        {
          label: '生产中',
          value: 'inProduction',
        },
        {
          label: '已作废',
          value: 'abolished',
        },
        {
          label: '已完成',
          value: 'completed',
        },
      ],
      reportSelectList: [
        {
          label: '可报工',
          value: 'yes',
        },
        {
          label: '不可报工',
          value: 'no',
        },
      ],
      keyword: '',
      messSingleProcessTaskStaticsDtoList: [],
      processId: '',
      // 导出参数

      selectedRowKeys: [],
      listIndeterminate: false,
      listCheckAll: false,
      exportUrl: '/wms/wmsGoodsWaterLevel/exportProductOrderReportXls',
      chooseArr: [],
      sortForm: {},
      allRequestList: [],
      fullName: `库存管理 ${moment(new Date()).format('YYYY-MM-DD HH:mm')}`,
      tableKey: 1.9,
    }
  },
  computed: {
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),
    computedWidth() {
      let str = {}
      if (this.isOpen && this.collapsed) {
        str.width = 'calc(100vw - 350px)'
      }
      if (!this.isOpen && this.collapsed) {
        str.width = 'calc(100vw - 130px)'
      }
      if (this.isOpen && !this.collapsed) {
        str.width = 'calc(100vw - 455px)'
      }
      if (!this.isOpen && !this.collapsed) {
        str.width = 'calc(100vw - 230px)'
      }
      return str
    },
    computedX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width)
      }

      return xnum
    },
    realFilterNum() {
      let nums = 0
      for (let key in this.realFilterForm) {
        if (this.realFilterForm[key] != '') {
          nums += 1
        }
      }
      return nums
    },
    filteredNums() {
      let nums = 0
      for (let key in this.filterForm) {
        if (this.filterForm[key] != '') {
          nums += 1
        }
      }
      return nums
    },
    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (this.filteredFormLable[key] == '类型') {
          let strArr = ''
          for (let item of this.filterForm[key]) {
            for (let each of this.typeList) {
              if (item == each.value) {
                strArr += each.title + '，'
              }
            }
          }
          strArr = strArr.substring(0, strArr.length - 1)
          list.push({
            title: this.filteredFormLable[key],
            text: strArr,
            key,
          })
        } else if (this.filteredFormLable[key] == '分类') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.treeSelectLael,
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
  },
  created() {
    let oldValue = localStorage.getItem(this.BUSI_CONST.Entity.STOCK_MANAGEMENT_LIST)
    this.columns = getNewColumns(allColumn, JSON.parse(oldValue), actionArr, this.columns)
    let leftObj = {
      keyword: this.keyword,
    }
    this.getLeftData(leftObj)
    this.getData()
    this.getTreeData()
    this.getDictModel()
  },
  methods: {
    handleDetail(v) {
      this.$refs.windowDetail.initDetail(v.goodsId)
    },
    getDictModel() {
      // 类型字典
      let parameters = { dictCode: 'wms_goods_type' }
      getDictModel(parameters).then((res) => {
        if (res.code == 200) {
          var arr = JSON.parse(JSON.stringify(res.result))
          // let arr = res.result
          arr.unshift({
            value: '0',
            title: '全部',
          })
          this.typeListTab = JSON.parse(JSON.stringify(arr))
          console.log(this.typeListTab, 'this.typeListTab')
          this.typeList = JSON.parse(JSON.stringify(res.result))
          console.log(res, 'inStockStatus')
        }
      })
    },
    getTreeData() {
      // 取分类树
      categoryGetTree({ code: 'B05' }).then((res) => {
        let arr = res.result
        arr.map((item) => {
          if (item.children.length > 0) {
            item.disabled = true
            ;(function bianli(e = item) {
              e.children.forEach((item) => {
                if (item.children.length > 0) {
                  item.disabled = true
                  bianli(item)
                }
              })
            })()
          }
        })
        this.treeData = arr
      })
    },
    treeChange(value, label, extra) {
      this.treeSelectLael = label[0]
    },
    // 点击 modal的取消按钮
    cancelAdd() {
      this.addDialog = false
      this.$refs['addForm'].resetFields()
    },
    openBach(record) {
      this.addDialog = true
      console.log(record, 'record')
      this.assistUnit = record.assistUnit
      this.newAddForm = { ...record }
      console.log(this.newAddForm)
    },

    //点击 新增||编辑仓库 的保存按钮
    saveAcction(addForm) {
      this.$refs[addForm].validate((valid) => {
        console.log(valid, 'validvalidvalid')
        if (valid) {
          console.log('ahahaha')
          this.accloading = true
          let submitApi = APILX.wmsGoodsWaterLevelAdd
          if (this.newAddForm.id) {
            submitApi = APILX.wmsGoodsWaterLevelEdit
          }
          let param = {
            id: this.newAddForm.id,
            goodsId: this.newAddForm.goodsId,
            maxNum: this.newAddForm.maxNum,
            securityNum: this.newAddForm.securityNum,
          }
          console.log(param, 'parameters')
          submitApi(param).then((res) => {
            console.log(res, 'res add edit')
            if (res.success) {
              this.$antdMessage.success(res.message)
              this.accloading = false
              this.cancelAdd()
              this.current = 1
              this.getData()
            } else {
              this.$antdMessage.warning(res.message)
            }
          })
        } else {
          return false
        }
      })
    },

    onCheck(checkedKeys, info) {
      console.log('onCheck', checkedKeys)
      let oldArr = this.treeDataLeftOld.map((i) => {
        return i.warehouseType
      })
      let newparam = checkedKeys.filter((item) => !oldArr.includes(item))
      this.selectedKeysTree = newparam.join()
      this.current = 1
      this.getData()
    },
    checkColor(row) {
      let colorStr = '#595959'
      if (row.goodsQualifiedNum && row.securityNum) {
        let goodsQualifiedNum = parseFloat(row.goodsQualifiedNum)
        let securityNum = parseFloat(row.securityNum)
        if (goodsQualifiedNum < securityNum) {
          colorStr = '#00b042'
        }
      }
      if (row.goodsQualifiedNum && row.maxNum) {
        let goodsQualifiedNum = parseFloat(row.goodsQualifiedNum)
        let maxNum = parseFloat(row.maxNum)
        if (goodsQualifiedNum > maxNum) {
          colorStr = '#ff4d4f'
        }
      }
      return colorStr
    },
    // itemClick(item, index) {
    //   if (item.processId != this.processId) {
    //     for (let each of this.messSingleProcessTaskStaticsDtoList) {
    //       each.isSelect = false
    //     }
    //     this.messSingleProcessTaskStaticsDtoList[index].isSelect = true
    //     this.processId = item.processId
    //     let params = this.formatData()
    //     let obj = {
    //       pageNo: this.current,
    //       pageSize: this.pageSize,
    //       ...params,
    //     }
    //     let secondParams = true
    //     this.getData(obj, secondParams)
    //   }
    // },
    getLeftData(obj) {
      APILX.getWmsWaterhouseTree(obj).then((res) => {
        if (res.success) {
          this.treeDataLeftOld = res.result
          res.result.forEach((item) => {
            if (item.warehouseType) {
              item.warehouseId = item.warehouseType
              item.warehouseName = item.warehouseTypeTxt
            }
          })
          this.treeDataLeft = res.result
          console.log(this.treeDataLeft, 'this.treeDataLeft')
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
    },
    checkList(dataIndex) {
      if (dataIndex == 'type') {
        return this.statusList
      } else {
        return this.reportSelectList
      }
    },
    searchProcess(value) {
      console.log(value, 'valuevaluevalue')
      let leftObj = {
        warehouseName: value,
      }
      this.getLeftData(leftObj)
    },
    clickgoodsCode(row) {
      this.$router.push({
        path: '/workOrderDetail',
        query: {
          id: row.orderId,
        },
      })
    },

    getData() {
      let obj = this.formatData()
      let params = {
        pageNo: this.current,
        pageSize: this.pageSize,
        type: this.type,
        warehouseId: this.selectedKeysTree,
        ...obj,
      }
      APILX.wmsGoodsWaterLevelList(params).then((res) => {
        if (res.success) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          console.log(res, 'resresreeeas')
          this.tableData = res.result.records
          this.allRequestList = this.allRequestList.concat(this.tableData)
          this.allRequestList = objArrFilter(this.allRequestList)
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
    },

    /* 打开筛选 */
    handleShowFilter() {
      this.filterForm = JSON.parse(JSON.stringify(this.realFilterForm))
      this.showFilter = true
    },

    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(allColumn, this.BUSI_CONST.Entity.STOCK_MANAGEMENT_LIST, columns)
      })
    },
    sureBtn(emitArr) {
      this.columns = getNewColumns(allColumn, emitArr, actionArr)
      console.log(this.emitArr)
      localStorage.setItem(this.BUSI_CONST.Entity.STOCK_MANAGEMENT_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    checkPlaceholder(dataIndex) {
      let str = ''
      switch (dataIndex) {
        case 'goodsCode':
          str = '请输入物品编号'
          break
        case 'goodsName':
          str = '请输入物品名称'
          break
        case 'spec':
          str = '请输入规格'
          break
        case 'category':
          str = '请选择分类'
          break
        case 'type':
          str = '请选择类型'
          break
      }
      return str
    },
    pubSearch(confirm, dataIndex, clearFilters) {
      confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥11：', confirm)
      console.log('这都是啥22：', dataIndex)
      this.filterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      this.realFilterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      // let params = this.formatData()
      // let obj = {
      //   pageNo: this.current,
      //   pageSize: this.pageSize,
      //   ...params,
      // }
      this.current = 1
      this.getData()
      // console.log('这都是啥33：', clearFilters)
    },
    // table
    tableChange(pagination, filters, sorter, { currentDataSource }) {
      // console.log('看看这是啥33：', sorter)
      let params = this.formatData()
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        let obj = {
          pageNo: this.current,
          pageSize: this.pageSize,
          ...params,
          sortType: sortType,
          sortColumn: sorter.columnKey,
        }
        this.getData(obj)
      } else {
        // let obj = {
        //   pageNo: this.current,
        //   pageSize: this.pageSize,
        //   ...params,
        // }
        this.getData()
      }
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      // console.log('第一个参数是；', selectedRowKeys)
      // console.log('第second个参数是；', selectedRows)
      this.selectedRowKeys = selectedRowKeys
      this.chooseArr = []
      for (let tag of selectedRowKeys) {
        for (let item of this.allRequestList) {
          if (tag == item.goodsId) {
            this.chooseArr.push(item)
          }
        }
      }
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.tableData) {
          tableIds.push(item.goodsId)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        console.log()
        console.log('第一个参数是；', checkValue)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    // 全选
    onCheckAllChange(e) {
      console.log('zhehsig', e.target)
      if (e.target.checked) {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.goodsId
          })
          this.chooseArr = this.chooseArr.filter((every) => {
            return every.goodsId != item.goodsId
          })
          this.selectedRowKeys.push(item.goodsId)
          this.chooseArr.push(item)
        }
      } else {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.goodsId
          })
          this.chooseArr = this.chooseArr.filter((every) => {
            return every.goodsId != item.goodsId
          })
        }
      }
      this.checkBoxStatus()
    },
    clearArr() {
      this.selectedRowKeys = []
      this.chooseArr = []
      this.checkBoxStatus()
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.getData()
    },
    onShowSizeChange(current, pageSize) {
      this.pageSize = pageSize
      this.current = current
      this.getData()
    },

    /* 确定筛选 */
    handleFilter() {
      // console.log('当前选择的是：', this.filterForm)
      // let params = this.formatData()
      // this.current = 1
      // let obj = {
      //   pageNo: this.current,
      //   pageSize: this.pageSize,
      //   ...params,
      // }
      this.current = 1
      this.getData()
      this.realFilterForm = JSON.parse(JSON.stringify(this.filterForm))
      this.tableFilterForm = JSON.parse(JSON.stringify(this.filterForm))
      this.showFilter = false
    },
    // 筛选传参数据
    formatData() {
      let copyForm = JSON.parse(JSON.stringify(this.filterForm))
      let params = {}
      //类型
      if (copyForm.type && copyForm.type.length > 0) {
        params.type = copyForm.type.join(',')
      } else {
        params.type = ''
      }
      //分类
      params.category = copyForm.category
      params.goodsCode = copyForm.goodsCode
      params.goodsName = copyForm.goodsName
      params.spec = copyForm.spec
      return params
    },
    /* 删除已选 */
    delFiltered(key) {
      if (this.filteredFormLable[key] == '物品编号') {
        this.filterForm[key] = []
      } else if (this.filteredFormLable[key] == '物品名称') {
        this.filterForm[key] = []
      } else if (this.filteredFormLable[key] == '分类') {
        this.filterForm[key] = []
        this.treeSelectLael = ''
      } else if (this.filteredFormLable[key] == '类型') {
        this.filterForm[key] = []
      } else if (this.filteredFormLable[key] == '审核状态') {
        this.filterForm[key] = []
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        goodsCode: '', //物品编号
        goodsName: '', //物品名称
        spec: '',
        category: [], //分类
        type: [], //类型
        // flowStatus: [], //审核状态
      }
      this.treeSelectLael = ''
      this.selectedKeys = []
      this.selectedKeysTree = []
      this.handleFilter()
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    checkShow(item) {
      let currentBoolean = Array.isArray(item)
      if (currentBoolean) {
        if (item.length == 0) {
          return false
        } else {
          return true
        }
      } else {
        if (item) {
          return true
        } else {
          return false
        }
      }
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.table-operations {
  margin-bottom: 16px;
}

.table-operations > button {
  margin-right: 8px;
}
.topBox {
  .flex(space-between, center);
  margin-bottom: 16px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
.pubColor {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}
/deep/ .ant-card-body {
  height: calc(100vh - 214px);
  overflow: hidden;
  padding: 20px 16px;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}

.cardBox {
  .flex(space-between, flex-start);
  .cardOne {
    width: 220px;
    margin-right: 16px;
    height: calc(100vh - 213px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #fff;

    // margin-top: 12px;
    box-sizing: border-box;
    .inputBox {
      box-sizing: border-box;
      padding: 20px 16px 0;
    }
  }
  .cardTwo {
    flex: 1;
  }
}
div.listBox {
  height: calc(100% - 77px);
  margin-top: 10px;
  overflow-y: auto;
  div.itemList {
    .flex(space-between, center);
    height: 34px;
    cursor: pointer;
    box-sizing: border-box;
    padding: 0 16px;
    div.itemLeft {
      font-size: 14px;
      color: #444444;
    }

    div.itemRight {
      font-size: 14px;
      color: #444444;
    }
  }
  div.haveColor {
    .flex(space-between, center);
    height: 34px;
    background: #e3f2ff;
    cursor: pointer;
    box-sizing: border-box;
    padding: 0 16px;
    div.itemLeft {
      font-size: 14px;
      color: #1890ff;
    }

    div.itemRight {
      font-size: 14px;
      color: #1890ff;
    }
  }
}
a {
  margin: 0;
}
</style>
